package com.lifesting.tool.j2as3.visitor;

import java.util.Arrays;

public final class TestClassHirerchy {
	public static void main(String[] args) {
		ClassHierarchy ch = new ClassHierarchy();
		ClassNode c1 = new ClassNode("com.lifesting.Figure");
		ClassNode c2 = new ClassNode("com.lifesting.Label");
		c1.addChild(c2);
		InterfaceNode i1 = new InterfaceNode("com.lifesting.IFigure");
		InterfaceNode i1_inserted = ch.insertInterface(i1);
		c1.addImplement(i1_inserted);
		
		ch.insertClass(c1);
		
		ClassNode c3 = new ClassNode("a.b.c.XFigure");
		InterfaceNode i2 = new InterfaceNode("com.lifesting.IFigure");
		InterfaceNode i2_inserted = ch.insertInterface(i2);
		c3.addImplement(i2_inserted);
		ch.insertClass(c3);
		
		ClassNode c4 = new ClassNode("com.lifesting.Label");
		ClassNode c5 = new ClassNode("com.lifesting.ImageLabel");
		c4.addChild(c5);
		ch.insertClass(c4);
		ClassNode c1_single = new ClassNode("com.lifesting.Figure");
		ch.insertClass(c1_single);
		ch.accept(new Visitor(){
			int level = 0;
			public void endVisit(Node n) {
				level--;			
			}

			public boolean visit(Node n) {
				level++;
				char[] cs = new char[level*4];
				Arrays.fill(cs, ' ');
				System.out.print(cs);
				System.out.print(n);
				if (n instanceof ClassNode){
					System.out.print(((ClassNode)n).getImplemented());
				}
				System.out.println();
				return true;
			}});
	}
}
